package cn.htsyb.synergy.tester.model;

import cn.htsyb.synergy.tester.adapter.IAdapter;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;

public class PlatBean {
    private static final Log defLog = LogFactory.getLog(PlatBean.class);

    private static TreeMap<String, OperateBean> globalOperatesMap;
    private static ArrayList<CaseBean> testCaseList;
    private static TreeMap<String, CaseBean> commCaseMap;
    private static Map<String, String> globalElementMap;
    private static Map<String, Object> globalParamMap;

    public PlatBean(IAdapter adapter) {
        try {
            globalOperatesMap = adapter.loadOperate();
            testCaseList = adapter.loadTestCase();
            commCaseMap = adapter.loadCommCase();
            globalElementMap = adapter.loadElement();
            globalParamMap = adapter.loadParam();
        } catch (Exception e) {
            defLog.error("系统配置加载失败,失败原因参考\n" + ExceptionUtils.getFullStackTrace(e));
        }
    }

    public static TreeMap<String, OperateBean> getOperatesMap() {
        return globalOperatesMap;
    }

    public static void setOperatesMap(TreeMap<String, OperateBean> operatesMap) {
        PlatBean.globalOperatesMap = operatesMap;
    }

    public static ArrayList<CaseBean> getTestCasesMap() {
        return testCaseList;
    }

    public static void setTestCasesMap(ArrayList<CaseBean> testCasesMap) {
        PlatBean.testCaseList = testCasesMap;
    }

    public static TreeMap<String, CaseBean> getCommCaseMap() {
        return commCaseMap;
    }

    public static void setCommCaseMap(TreeMap<String, CaseBean> commCaseMap) {
        PlatBean.commCaseMap = commCaseMap;
    }

    public static Map<String, String> getGlobalElementMap() {
        return globalElementMap;
    }

    public static void setGlobalElementMap(Map<String, String> globalElementMap) {
        PlatBean.globalElementMap = globalElementMap;
    }

    public static Map<String, Object> getGlobalParamMap() {
        return globalParamMap;
    }

    public static void setGlobalParamMap(Map<String, Object> globalParamMap) {
        PlatBean.globalParamMap = globalParamMap;
    }

}
